package weiconsole.ui;

import weiconsole.Main;

public class NativeUI {
	public static final short CL_BLACK = 0;
	public static final short CL_RED = 1;
	public static final short CL_GREEN = 2;
	public static final short CL_LIGHTRED = 3;
	public static final short CL_BLUE = 4;
	public static final short CL_PURPLE = 5;
	public static final short CL_LIGHTBLUE = 6;
	public static final short CL_GRAY = 7;
	public static final short CL_NORMAL = 8;
	public static final short CL_WHITE = 0;
	private int scrRow = 0, scrCol = 0;
	
	static {
		try {
			System.setProperty("java.library.path", "lib/linux");
			System.loadLibrary("nativeui");
		}catch(UnsatisfiedLinkError e) { 
			Main.error("cannot load native UI library: " + e.toString()); 
		} 
	}
	
	public NativeUI() {
		scrRow = getScrRow();
		scrCol = getScrCol();
	}
	
	public int scrRow() { return scrRow; }
	public int scrCol() { return scrCol; }
	
	public native void setBackground(short color);
	public native void setForeground(short color);
	public native void cleanScreen();
	public native void saveCursorPos();
	public native void restoreCursorPos();
	public native void moveCursor(int x, int y);
	public native int getScrRow();
	public native int getScrCol();
}
